﻿#include "newcanvasdlg.h"
#include "ui_newcanvasdlg.h"
#include <QRegExpValidator>

NewCanvasDlg::NewCanvasDlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::NewCanvasDlg)
{
    ui->setupUi(this);
    QRegExp rx("^(([1-9]\\d{0,2})|([1-3][0-9][0-9][0-9]))$");
    QValidator*validator = new QRegExpValidator(rx);
    ui->editWidth->setValidator(validator);
    ui->editHeight->setValidator(validator);
    ui->editWidth->setText("800");
    ui->editHeight->setText("600");
    this->setWindowTitle(QStringLiteral("新建画布"));
}

NewCanvasDlg::~NewCanvasDlg()
{
    delete ui;
}

void NewCanvasDlg::on_btnOK_clicked()
{
    m_iWidth = ui->editWidth->text().toInt();
    m_iHeight = ui->editHeight->text().toInt();
    done(Accepted);
}

void NewCanvasDlg::on_btnCancel_clicked()
{
    done(Rejected);
}
